Field of the Invention
The present invention relates to an image encoding apparatus, an image encoding method and a storage medium, and it particularly relates to an adaptive control over an amount of code within a frame.
Description of the Related Art
H.264/MPEG-4 AVC (hereinafter, H.264) has been known as an encoding scheme usable for compressing and recording a moving image. (ITU-T H.264 (March 2010) Advanced video coding for generic audiovisual services) When H.264 is used to encode an image in blocks, the quantization value is variable for each block. Controlling the quantization value in blocks allows control of the amount of code to be assigned to each block and thus control over image quality of each block.
In the past, when such an encoding scheme is used to encode an image, an increase of the amount of code may be inhibited while inhibiting degradation of image quality by controlling the amount of code in the following manner. That is, blocks of images in one frame are classified based on the visual characteristic of human beings, and a lower value than a reference quantization value is assigned as a quantization value for a block belonging to a class for remarkable degradation of image quality in the visual characteristic of human beings to inhibit degradation of image quality. Here, such a reference quantization value may be a frame QP or a slice QP, for example.
On the other hand, a higher value than the reference quantization value may be assigned as a quantization value for a block belonging to a class for unremarkable degradation of image quality to inhibit an increase of the amount of code of the block belonging to the class. However, according to the method in the past, when the number of blocks belonging to a class for remarkable degradation of image quality increases in one frame, a lower quantization value than the reference quantization value is assigned to more blocks, which disadvantageously increases the amount of code in one frame. Against this, the quantization value to be assigned to the blocks must be controlled in consideration of the number of blocks belonging to the classes.
For example, a technology in the past divides one frame into 16×16 pixel blocks based on the visual characteristic of human beings, and the 16×16 pixel encoded blocks are classified (into a class A). Then, a reference quantization value is provided for each of the classes A. Each of 8×8 pixel blocks (sub-blocks) is classified into a class B based on a variance value for the 8×8 pixel blocks. Thus, a histogram of the number of blocks of the class A and class B is generated. A generated bit amount for each frame is predicted based on the histogram and the reference quantization value, and the reference quantization value for each class is adjusted based on the predicted bit amount.
However, the technology in the past must determine a quantization value to be assigned to each class in consideration of the number of blocks belonging to all classes in each frame in order to predict the generated bit amount for the frame. Thus, an increased number of bits may be required for determining a quantization value in consideration of the number of blocks belonging to all classes for one frame according to the technology in the past. This may increase the computational cost for predicting the generated bit amount for one frame.